package com.hqyj.onlineExamination.modules.exam.controller;


import com.hqyj.onlineExamination.modules.common.entity.ResultEntity;
import com.hqyj.onlineExamination.modules.common.entity.SubmitPaperBean;
import com.hqyj.onlineExamination.modules.exam.entity.Achievement;
import com.hqyj.onlineExamination.modules.exam.service.AchievementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


@RestController
@RequestMapping("/api")
public class AchievementController {

    @Autowired
    AchievementService achievementService;

    //交卷
    @PostMapping(value = "/achievement",consumes = "application/json")
    public ResultEntity<Achievement> submitPaper(@RequestBody SubmitPaperBean submitPaperBean){
        return achievementService.insertAchievement(submitPaperBean);
    }

    //批改试卷初始化试卷
    @GetMapping("/achievement/{id}")
    public ResultEntity<Map<String,Object>> getAchievementById(@PathVariable int id) {
        return achievementService.getAchievementById(id);
    }

    //批改试卷
    @PostMapping(value = "/achievementScore",consumes = "application/json")
    public ResultEntity correction(@RequestBody Achievement achievement){
        System.out.println(achievement.getScore());
        return achievementService.correction(achievement);
    }
}
